package com.aegean.MonitorExamSYS.android.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Controller("ExamPhotoForAndroid")
@Scope("prototype")
public class ExamPhotoForAndroid extends ActionSupport {
	private int small_Id;
	private String exam_PhotoName;
	public int getSmall_Id() {
		return small_Id;
	}

	public void setSmall_Id(int small_Id) {
		this.small_Id = small_Id;
	}

	public String getExam_PhotoName() {
		return exam_PhotoName;
	}

	public void setExam_PhotoName(String exam_PhotoName) {
		this.exam_PhotoName = exam_PhotoName;
	}


	public InputStream getDownload() {
		try {
			String root = ServletActionContext.getServletContext().getRealPath(
					"/dateFile/examInfo/" + small_Id);
			File photo = new File(root + "/" + exam_PhotoName);
			InputStream in = new FileInputStream(photo);
			return in;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

}
